Learnerslesson
   JAVA   
  SPRING  
  SPRINGBOOT  
 HIBERNATE 
  HADOOP  
   HIVE   
   ALGORITHMS   
   PYTHON   
   GO   
   KOTLIN   
   C#   
   RUBY   
   C++   




pop( ) FUNCTION


The 'pop( )' Function can be used to remove an item from the Set. But it does not remove the last element.


As there is no indexing, the 'pop( )' Function could remove any element.


Example :


x = {"Mohan", "Kriti", "Salim"}
x.pop()
print(x) 


Output :



  {'Kriti', 'Salim'}

So, in the above code we have created a 'Set' and initialised to the variable 'x'.


x = ["Mohan", "Kriti", "Salim"]

Below is how the values are positioned in the Set,


java_Collections

Next, we have used the 'pop( )' function that can remove any element from the Set.


x.pop( )

In this case 'Mohan' is removed from the Set.


java_Collections

And we get the below output,


{'Kriti', 'Salim'}